﻿using MiniExcelLibs;
using System;
using System.Collections.Generic;
using System.IO;

namespace Qy.Scenario;

public class ExcelHelperAction
{

    /// <summary>
    /// 导出Excel
    /// </summary>
    public static string ExportExcel<T>(List<T> list, string fileName)
    {
        string sFileName = $"{fileName}{DateTime.Now:MMddHHmmss}.xlsx";
        string newFileName = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "export", sFileName);
        Directory.CreateDirectory(Path.GetDirectoryName(newFileName));
        MiniExcel.SaveAs(newFileName, list);
        return sFileName;
    }
}


